package ph.com.isla.sf2d.ui;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.util.Log;

public class SF2DBorder {
	private float mThickness;
	private int mColor;
	private Paint mPaint;
	private Rect mRect;
	private SF2DObject mObject;

	public SF2DBorder(float thickness, int color) {
		mThickness = thickness;
		mColor = color;

	}

	void setSF2DObject(SF2DObject object) {
		if (object == null)
			return;
		
		mObject = object;
		initialize();
	}
	
	RectF getInnerRect(){
		RectF rect = SF2DUtil.createInnerRect(mThickness, mObject.getDimension());
		return rect;
	}

	private void initialize() {
		if (mThickness > 0) {
			mPaint = new Paint();
			mPaint.setStyle(Style.STROKE);
			mPaint.setColor(mColor);

			mRect = new Rect();
			mRect.left = mObject.getDimension().left;
			mRect.top = mObject.getDimension().top;
			mRect.right = mObject.getDimension().right;
			mRect.bottom = mObject.getDimension().bottom;
		}

	}

	public void draw(Canvas canvas) {
		initialize();
		canvas.drawRect(mRect, mPaint);
	}
}
